// class Solution {
// public:
//     int findKthLargest(vector<int>& nums, int k) {
//         priority_queue<int> myHop;
//         for (auto i : nums)
//             myHop.push(i);

//         while (--k)
//             myHop.pop();

//         return myHop.top();
//     }
// };

class Solution {
public:
    int findKthLargest(vector<int>& nums, int k) {
        priority_queue<int, vector<int>, greater<int>> myHop;
        for (int i = 0; i < k; i++)
            myHop.push(nums[i]);

        for (int i = k; i < nums.size(); i++)
        {
            if (nums[i] > myHop.top())
            {
                myHop.pop();
                myHop.push(nums[i]);
            }
        }

        return myHop.top();
    }
};